package com.zjitc.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.zjitc.mapper.UserMapper;
import com.zjitc.pojo.MyUser;
@Controller
public class TestController {
    @Autowired
    private UserMapper userMapper;
    @GetMapping("/test")
    public String test() {
        // 查询一个用户
        MyUser mu = userMapper.selectUserById(1);
        System.out.println(mu);
        // 添加一个用户
        MyUser addmu = new MyUser();
        addmu.setUserId(1);
        addmu.setUserName("陈恒");
        addmu.setPassword("123456");
        userMapper.addUser(addmu);
        // 修改一个用户
        MyUser updatemu = new MyUser();
        updatemu.setUserId(1);
        updatemu.setUserName("张三");
        updatemu.setPassword("2366980");
        userMapper.updateUser(updatemu);

        // 查询所有用户
        List<MyUser> listMu = userMapper.selectAllUser();
        for (MyUser myUser : listMu) {
            System.out.println(myUser);
        }

        // 删除一个用户
        userMapper.deleteUser(1);
        return "test";
    }
}
